package com.prb.consumer.consumer;

import com.prb.common.config.RpcConfig;
import com.prb.common.service.UserService;
import com.prb.consumer.proxy.RpcConsumer;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.io.IOException;

public class ConsumerMain {

    public static void main(String[] args) throws IOException, InterruptedException {

        test();

    }

    private static void test() throws IOException, InterruptedException {

        //关闭调用 耗时统计
        RpcConfig.serverSide = "server";

        //spring 容器加载
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.scan("com.prb.consumer.config" , "com.prb.register.factory" , "com.prb.consumer.register");
        context.refresh();

        //动态代理的创建
        UserService userService = (UserService) RpcConsumer.instance.getProxy(UserService.class);

        while (true){
            String msg = userService.getUserMsg("xixi");
            System.out.println("result is =================> : " + msg);

            //System.out.println("普通调用=================");
            Thread.sleep(6000);
        }


    }

}
